home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / MouseInfo 1.0.1 / About.cp next >
Encoding:
Text File  |  1992-07-15  |  2.9 KB  |  106 lines  |  [TEXT/MPS ]

  1. //     About.cp
  2. //     Copyright © 1992 by Apple Computer, Inc. All rights reserved.
  3. //    Kent Sandvik DTS
  4. //    This file contains the About box code including any adorners/behaviors
  5. //    The resources are placed in the project .r file
  6. //    Version Info (latest first):
  7. //
  8. //    <1>        khs        1.0        First final version
  9. //    <2>        khs        1.0.1    Fixed a memory leak in TMapApplication::GetSleepValue()
  10.  
  11.  
  12. #ifndef __ABOUT__
  13. #include "About.h"
  14. #endif
  15.  
  16.  
  17. //    Functions
  18.  
  19. #pragma segment ARes
  20. void CreateAboutBox()
  21. {
  22.     TWindow * aboutBoxWindow;
  23.     CStr255 programName,  versionInfo, finalProduct;
  24.  
  25.     //    Yes, I do know this is a waste of resources to 'macroDontDeadStrip' and
  26.     //    register the adorner type every time we open the About box. However, for the
  27.     //    sake of modularity, where I only need to place a CreateAboutBox() statement
  28.     //    inside the TApplication->DoAboutBox(), it made sense - instead of writing all
  29.     //    kinds of init methods that need to be called from IApplication.
  30.  
  31.     if (gDeadStripSuppression)                    // so the linker doesn't dead strip class info 
  32.         macroDontDeadStrip(TMetalBlueFill);
  33.  
  34.     RegisterStdType("TMetalBlueFill", kBlueMetalLook);// register adorner types
  35.  
  36.     //    Get application name    
  37.     gApplication->GetApplicationName(programName);
  38.  
  39.     //    Get version information
  40.     VersRecHndl versInfo = (VersRecHndl)GetResource(kVersInfoType, kVers1InfoID);
  41.     if (versInfo)                                // short one?
  42.         versionInfo = (**versInfo).shortVersion;// get version info from version 1
  43.     else
  44.         versionInfo = " ";                        // nooooothing
  45.  
  46.  
  47.     //    Create Window
  48.     aboutBoxWindow = gViewServer->NewTemplateWindow(phAboutBox, NULL);
  49.     FailNIL(aboutBoxWindow);
  50.  
  51.     //    Hook in any adorners
  52.     aboutBoxWindow->AddAdorner(NewStdAdorner('blmt', "", 'blmt', kFreeOnDeletion), kAdornBefore, kRedraw);
  53.  
  54.     // Stuff in the version info to the other status view, but first get a ptr to it...
  55.     TStaticText * versionField = (TStaticText *)aboutBoxWindow->FindSubView('sta2');
  56.     finalProduct = programName + CStr255(" ") + versionInfo;
  57.     versionField->SetText(finalProduct, TRUE);
  58.  
  59.     //    Open the About box window, and let the user close it whenever...
  60.     aboutBoxWindow->Open();
  61. }
  62.  
  63.  
  64. //    About Box color adorner
  65.  
  66. CRGBColor gMetalBlue(26312,
  67.                      14340,
  68.                      47359);                    // Setup the metal-blue color
  69.  
  70.  
  71. //    Empty constructor - for avoiding ptabs in global data space
  72. #pragma segment ARes
  73. TMetalBlueFill::TMetalBlueFill()
  74. {
  75. }
  76.  
  77.  
  78. //    Draw TGrayFill Adorner method
  79.  
  80. #pragma segment ARes
  81. pascal void TMetalBlueFill::Draw(TView* itsView,
  82.                                  const VRect&    /*area*/)
  83. {
  84.     CRGBColor saveColor;
  85.     PenState savePenState;
  86.     VRect adornArea;
  87.     CRect QDArea;
  88.     CRect tempRect;
  89.  
  90.     GetPenState(savePenState);                    // save off the current pen state 
  91.     GetIfColor(saveColor);                        // and the foreground color
  92.     PenNormal();
  93.  
  94.     itsView->GetAdornExtent(adornArea);            // get area
  95.     itsView->ViewToQDRect(adornArea, QDArea);
  96.     tempRect = QDArea;
  97.  
  98.     SetIfColor(gMetalBlue);                        // colorize it
  99.     PaintRect(tempRect);
  100.  
  101.     SetIfColor(saveColor);                        // restore the foreground color and the pen
  102.     SetPenState(savePenState);
  103. }
  104.  
  105.  
  106.